<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="button" value="点击" id="btn">
<p id="btnP"></p>
<div id="ligth" onmouseup="mup(this)"; onmousedown="mdown(this)"; onmouseover="mover(this)"; onmouseleave="mout(this)" style="width: 100px;height: 100px;background: green;padding: 10px;text-align: center"></div>
</body>
<script type="text/javascript">

        document.getElementById('btn').onclick = function (ev) {
            document.getElementById('btnP').innerHTML = new Date();
        }

        function mover(obj) {
            obj.innerHTML = 'come';
        }
        function mout(obj) {
            obj.innerHTML= 'out';
        }
        function mdown(obj) {
            obj.style.backgroundColor = 'red';
        }

        function mup(obj) {
            obj.style.backgroundColor = 'green';
        }
        var init;
        var time;
        function light() {
            window.clearInterval(time);
            init = setInterval(time,1000);
            var init2 = init;
            if(init - init2== 1000){
                document.getElementById('light').style.backgroundColor= '#123'
            }
        }

        if(typeof(String.prototype.trim) === "undefined")
        {
            String.prototype.trim = function()
            {
                return String(this).replace(/^\s+|\s+$/g, '');
            };
        }
        if(" dog  " === "dog") {
            document.write("这里不会显示");
        }
        if(" dog  ".trim() === "dog") {
            document.write("成功去除首尾空格");
        }

</script>
</html>